package ui;

import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import draft.*;


public class DraftClient extends JFrame {
	
	OrderPanel op;
	JLabel label;
	JPanel panel;
	public FantasyManager manager;
	
	
	public DraftClient(){
		super("Fantasy Football Draft Client");
		setSize(600,600);
		setLocation(0,0);
		String s = JOptionPane.showInputDialog(this, "How many teams are in your League?");
		int size;
		try {
			size = Integer.parseInt(s.trim());
	    
		    Object[] picks = new Object[size];
		    for (int i = 1; i <= size; i++){
		    	picks[i-1] = i;
		    }
		    int userPick = (Integer) JOptionPane.showInputDialog(this, "What Number Draft Pick are You?", "Set-up", JOptionPane.PLAIN_MESSAGE, null, picks, picks[0]);
		    manager = new FantasyManager(size, userPick-1);
		    JPanel mainpanel = new JPanel();
		    mainpanel.setSize(600,600);
		    mainpanel.setLocation(0,0);
		    mainpanel.setLayout(new GridLayout(2, 1));
		    panel = new JPanel();
		    panel.setLayout(new GridLayout(2,1));
		    op = new OrderPanel();
		    panel.add(op);
		    label = new JLabel("Input Opponent Draft Pick");
		    label.setHorizontalAlignment(SwingConstants.CENTER);
		    label.setFont(new Font("sans serif", Font.BOLD, 16));
		    panel.add(label);
		    mainpanel.add(panel);
		    mainpanel.add(new PlayerPanel());
		    add(mainpanel);
			setVisible(true);
			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		} catch (NumberFormatException nfe) {
		      System.out.println("NumberFormatException: " + nfe.getMessage());
		}
	}
	

	void advanceTurn(){
		op.updateText();
	}
	
	public void setMainLabel(String s){
		label.setText(s);
		label.repaint();
	
		
	}

}
